/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Control;

import DAO.RecursoDAO;
import Model.Recurso;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;

/**
 *
 * @author 0433101
 */
public class validaRecurso extends Processor {

    @Override
    public void execute() throws ServletException, IOException {
        String nome = getRequest().getParameter("nome");
        PrintWriter out = getResponse().getWriter();
        try {
            Recurso recurso = RecursoDAO.pesquisarByNome(nome);
            
            if(recurso == null){
                out.println("<font color='green'> Recurso válido! </font>");
            }else{
                out.println("<font color='red'> Recurso já existe! </font>");
            }
        } catch (SQLException ex) {
            throw new ServletException(ex);
        } catch (ClassNotFoundException ex) {
            throw new ServletException(ex);
        }
    }
    
}
